//
//  BDCustomerServiceViewController.m
//  BeidouMall
//
//  Created by qie on 16/6/7.
//  Copyright © 2016年 qie. All rights reserved.
//

#import "BDCustomerServiceViewController.h"

@interface BDCustomerServiceViewController ()
{
    NSString *_phoneNum;
}
@property (weak, nonatomic) IBOutlet UILabel *promitLabel;

@end

@implementation BDCustomerServiceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    self.promitLabel.text = NSLocalizedString(@"Customer service daily 9:00 to 17:00 Online", nil);
    if ([[BDAccountManagerModel shareInstance].langage isEqualToString:@"zang"]) {
        [self.navigationController.navigationBar
         setTitleTextAttributes:
         @{NSFontAttributeName:[UIFont fontWithName:@"BZDHT" size:12.0]}];
        self.promitLabel.font = [UIFont fontWithName:@"BZDHT" size:9.0];
    } else {
        [self.navigationController.navigationBar
         setTitleTextAttributes:
         @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18.0]}];
    }
    self.title = NSLocalizedString(@"Customer service", nil);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UIAlertView delegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_phoneNum]];
    }
}

#pragma mark - IBActions

- (IBAction)callPhoneButtonPressed:(UIButton *)sender {
    _phoneNum = [NSString stringWithFormat:@"tel://%@",sender.currentTitle];
    NSString *promit;
    if ([[BDAccountManagerModel shareInstance].langage isEqualToString:@"zang"]) {
        promit = [NSString stringWithFormat:@"霸︽斑半︽%@伴巢︽搬佰爸︽搬邦扳︽驳邦︽翟稗︽拜扳﹀?",sender.currentTitle];
        NSArray * buttons = @[NSLocalizedString(@"Confirm", nil), NSLocalizedString(@"Cancel", nil)];
        TAlertView *alert = [[TAlertView alloc] initWithTitle:@""
                                                      message:promit
                                                      buttons:buttons
                                                  andCallBack:^(TAlertView *alertView, NSInteger buttonIndex) {
                                                      if (buttonIndex == 0) {
                                                          [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_phoneNum]];
                                                      }
                                                  }];
        alert.messageFont = [UIFont fontWithName:@"Bzdbt" size:16.0];
        alert.buttonsFont = [UIFont fontWithName:@"Bzdbt" size:16.0];
        [alert show];
        return;
    } else if ([[BDAccountManagerModel shareInstance].langage isEqualToString:@"en"]) {
        promit = [NSString stringWithFormat:@"Sure to call %@?",sender.currentTitle];
    } else {
        promit = [NSString stringWithFormat:@"%@%@吗?",NSLocalizedString(@"Customer service daily 9:00 to 17:00 Online", nil),sender.currentTitle];
    }
    
    UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"" message:promit delegate:nil cancelButtonTitle:NSLocalizedString(@"Confirm", nil) otherButtonTitles:NSLocalizedString(@"Cancel", nil), nil];
    alter.delegate = self;
    [alter show];
    
    
}

- (IBAction)backButtonPressed:(UIBarButtonItem *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
